/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.bean;

import com.minierp.model.MakeType;
import java.util.Comparator;

public class MakeTypeComparator implements Comparator {
	public int compare(Object obj1, Object obj2)
  {
    String code1 = ((MakeType)obj1).getSequCode();
    String code2 = ((MakeType)obj2).getSequCode();
    if ((((code1 == null) || (code1.equals("")))) && (((code2 == null) || (code2.equals("")))))
      return ((MakeType)obj1).getTypeName().compareTo(((MakeType)obj2).getTypeName());
    if ((code1 == null) || (code1.equals("")))
      return -1;
    if ((code2 == null) || (code2.equals(""))) {
      return 1;
    }
    String[] arr1 = code1.split("\\.");
    String[] arr2 = code2.split("\\.");
    int maxLen = arr1.length;
    if (arr2.length > maxLen) {
      maxLen = arr2.length;
    }
    int retVal = 0;
    for (int i = 0; i < maxLen; ++i) {
      if (arr1.length <= i) {
        return -1;
      }
      if (arr2.length <= i) {
        return 1;
      }
      int v1 = 0; int v2 = 0;
      try {
        v1 = Integer.parseInt(arr1[i]);
        v2 = Integer.parseInt(arr2[i]);
        if (v1 < v2) {
          retVal = -1; break;
          }
        if (v1 == v2) {
          retVal = 0; break;
        }
        retVal = 1;
      }
      catch (Exception e)
      {
        retVal = arr1[i].compareTo(arr2[i]);
      }
      if (retVal != 0) {
        label234: return retVal;
      }
    }
    return retVal;
  }
}